package com.qf.contract.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.common.base.exception.ServiceException;
import com.qf.common.base.result.ResultCode;
import com.qf.contract.entity.FTypeOfContract;
import com.qf.contract.mapper.FTypeOfContractMapper;
import com.qf.contract.service.FTypeOfContractService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class FTypeOfContractServiceImpl implements FTypeOfContractService {
    @Resource
    FTypeOfContractMapper fTypeOfContractMapper;

    @Override
    public int addFTypeOfContract(FTypeOfContract fTypeOfContract) {
        try {
            return fTypeOfContractMapper.insert(fTypeOfContract);
        } catch (Exception e) {
            throw new ServiceException(ResultCode.SYS_ERROR);
        }
    }

    @Override
    public int delFTypeOfContract(int id) {
        try {
            return fTypeOfContractMapper.deleteById(id);
        } catch (Exception e) {
            throw new ServiceException(ResultCode.SYS_ERROR);
        }

    }

    @Override
    public int upFTypeOfContract(FTypeOfContract fTypeOfContract) {
        try {
            return fTypeOfContractMapper.updateById(fTypeOfContract);
        } catch (Exception e) {
            throw new ServiceException(ResultCode.SYS_ERROR);
        }
    }

    @Override
    public Page<FTypeOfContract> selectFTypeOfContract(int current, int size) {
        try {
            Page<FTypeOfContract> fChangeRequestPage = fTypeOfContractMapper.selectPage(new Page<>(current, size), null);
            return fChangeRequestPage;
        } catch (Exception e) {
            throw new ServiceException(ResultCode.SYS_ERROR);
        }
    }
}
